package com.ren.common.exception;

import com.ren.common.result.ResponseEnum;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author RenGaoshuai
 * @date 2023/8/7 15:42
 * @description
 */
@Data
@NoArgsConstructor
public class BusinessException extends RuntimeException {
    //状态码
    private Integer code;

    //错误消息
    private String message;

    public BusinessException(Integer code) {
        this.code = code;
        this.message = ResponseEnum.getInstance(code).getMessage();
    }

    public BusinessException(String message) {
        this.code = ResponseEnum.ERROR.getCode();
        this.message = message;
    }

    public BusinessException(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public BusinessException(ResponseEnum responseEnum) {

        this.code = responseEnum.getCode();
        this.message = responseEnum.getMessage();
    }


}
